﻿<%@ Page Title="" Language="C#" MasterPageFile="~/ACM.Master" AutoEventWireup="true" CodeBehind="TMTSearch.aspx.cs" Inherits="ACM.TMTSearch" %>

<%@ Register Src="~/UserControls/StatusPanel.ascx" TagPrefix="uc" TagName="StatusPanel" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .input-group {
            margin-top: 10px;
        }

        .avoidBootstrap th {
            text-align: center;
        }

        .avoidBootstrap td {
            padding: 3px;
        }

        .action {
            text-align: center;
        }

            .action a:link {
                color: #222222;
            }

        table label {
            font-weight: normal;
        }

        .Pagination {
            line-height: 30px;
            background-color: #ECDBFF;
            text-align: center;
        }

            .Pagination a:link, .Pagination a:visited {
                color: black;
            }

        .gridResult th, .gridResult td {
            border: 1px solid #fff;
            font-size: 12px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="StatusPlaceHolder" runat="server">
    <uc:StatusPanel ID="Status" runat="server"></uc:StatusPanel>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="content" runat="server">
    <h1 class="page-header">ค้นหา</h1>

    <div class="row">
        <div class="col-md-8 col-md-offset-2">

             <div id="divBarcodeLabel" runat="server"><span class=" glyphicon glyphicon-search"></span>ค้นหาด้วย Barcode</div>
            <div class="input-group" id="divBarcode" runat="server">
                <span class="input-group-addon"><span class="glyphicon glyphicon-barcode"></span></span>
                <asp:TextBox ID="txtBarcode" CssClass="form-control" TextMode="MultiLine" Rows="5" placeholder="สำหรับยิง Barcode" runat="server"></asp:TextBox>
            </div>
            <div id="divLabel" runat="server">
                <br />
                <span class=" glyphicon glyphicon-search"></span>หรือค้นหาด้วยข้อมูลอื่นๆ
            </div>

            <div class="input-group">
                <span class="input-group-addon"><span class="glyphicon glyphicon-search"></span></span>
                <asp:TextBox ID="txtKeyword" CssClass="form-control" placeholder="กรุณากรอกรหัสตัวแทนจำหน่าย หรือ ชื่อตัวแทนจำหน่าย " runat="server"></asp:TextBox>
            </div>
            <div class="row">
                <div class="col-md-5">
                    <div class="input-group">
                        <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                        <asp:TextBox ID="txtSrtDate" CssClass="form-control dateInput" placeholder="จากวันที่" runat="server"></asp:TextBox>
                    </div>
                </div>
                <div class="col-md-5">
                    <div class="input-group">
                        <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                        <asp:TextBox ID="txtEndDate" CssClass="form-control dateInput" placeholder="ถึงวันที่" runat="server"></asp:TextBox>
                    </div>
                </div>
                <div class="col-md-2">
                    <asp:Button ID="btnSearch" runat="server" CssClass="btn btn-primary" Text="ค้นหา" Style="width: 100px; float: right; margin-top: 10px;" OnClick="btnSearch_Click" />
                </div>
            </div>

            <div class="row">
                <div class="col-md-6 col-md-offset-3">
                    <br />
                    <table width="100%">
                        <tr>
                            <td>
                                <asp:CheckBox ID="CheckBox1" runat="server" Text="&nbsp;ตรวจสอบเอกสาร" /></td>
                            <td>
                                <asp:CheckBox ID="CheckBox2" runat="server" Text="&nbsp;เอกสารครบ" /></td>
                        </tr>
                        <tr>
                            <td>
                                <asp:CheckBox ID="CheckBox3" runat="server" Text="&nbsp;เอกสารไม่สมบูรณ์" /></td>
                            <td>
                                <asp:CheckBox ID="CheckBox4" runat="server" Text="&nbsp;จ่ายแล้ว" /></td>
                        </tr>
                    </table>
                </div>
            </div>

        </div>
    </div>

    <div class="row" style="margin-top: 20px;">
        <div class="avoidBootstrap">

            <div style="text-align: right; margin-bottom: 5px;" id="divTop" runat="server" visible="false">
                Selecct All
                <input type="checkbox" id="selectallTop" />&nbsp;
            </div>
            <asp:GridView ID="grdResult" runat="server" Width="100%" CellPadding="4" EnableModelValidation="True" ForeColor="#333333" GridLines="None" AutoGenerateColumns="False" CssClass="gridResult" OnRowCommand="grdResult_RowCommand" OnRowDataBound="grdResult_RowDataBound">
                <AlternatingRowStyle BackColor="White" />
                <Columns>
                    <asp:BoundField DataField="RowNumber" HeaderText="No." SortExpression="rec_no" ItemStyle-Width="30px">
                        <ItemStyle HorizontalAlign="Center" />
                    </asp:BoundField>
                    <asp:BoundField HeaderText="Dealer Code" DataField="tx_dealer_code" ItemStyle-HorizontalAlign="Center">
                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                    </asp:BoundField>
                    <asp:BoundField HeaderText="ชื่อตัวแทนจำหน่าย" DataField="dealer_name" ItemStyle-Height="30" ItemStyle-HorizontalAlign="Center">
                        <ItemStyle HorizontalAlign="Center" Height="30px"></ItemStyle>
                    </asp:BoundField>
                    <asp:BoundField HeaderText="Dealer ที่ตัดขาย" DataField="owner_dealer" ItemStyle-HorizontalAlign="Center">
                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                    </asp:BoundField>
                    <asp:BoundField HeaderText="ชื่อ - นามสกุล" DataField="customer_name" ItemStyle-HorizontalAlign="Center">
                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                    </asp:BoundField>
                    <asp:BoundField HeaderText="VIN" DataField="vin" ItemStyle-HorizontalAlign="Center">
                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                    </asp:BoundField>
                    <asp:BoundField HeaderText="รุ่นรถ" DataField="car_series" ItemStyle-HorizontalAlign="Center">
                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                    </asp:BoundField>

                    <asp:TemplateField HeaderText="รุ่นย่อย" ItemStyle-HorizontalAlign="Center">
                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                        <ItemTemplate>
                            <asp:Label ID="lblSubSeries" runat="server" Text='<%# Eval("car_sub_series") %>'></asp:Label>/<asp:Label ID="lblSuffix" runat="server" Text='<%# Eval("car_suffix") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    
                    <asp:BoundField HeaderText="วันที่ตัดขาย" DataField="adv_date" ItemStyle-HorizontalAlign="Center" DataFormatString="{0:dd/MM/yyyy}">
                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                    </asp:BoundField>
                    <asp:BoundField HeaderText="วันที่ส่งมอบ" DataField="dlv_date" ItemStyle-HorizontalAlign="Center" DataFormatString="{0:dd/MM/yyyy}">
                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                    </asp:BoundField>

                    <asp:BoundField HeaderText="แคมเปญ" DataField="campaign_name" ItemStyle-HorizontalAlign="Center" Visible="False">
                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                    </asp:BoundField>
                    <asp:BoundField HeaderText="ยอดที่ได้รับ" DataField="diff_promotion_amount" ItemStyle-HorizontalAlign="Center" DataFormatString="{0:n0}">
                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                    </asp:BoundField>
                    <asp:BoundField HeaderText="Note4" DataField="mobile_note4" ItemStyle-HorizontalAlign="Center">
                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                    </asp:BoundField>
                    <asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderText="สถานะ">
                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                        <ItemTemplate>
                            <asp:Label ID="lblStatus" runat="server" Text='<%# Eval("tx_status") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderText="RO">
                        <ItemStyle HorizontalAlign="Center"></ItemStyle>
                        <ItemTemplate>
                            <asp:Image ID="imgRoViewed" runat="server" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:LinkButton ID="lnkView" runat="server" CommandName="ViewTx" CommandArgument='<%# Eval("id") %>'><span class="glyphicon glyphicon-list"></span></asp:LinkButton>&nbsp;
                            <asp:HyperLink ID="lnkDoc" runat="server">
                                <span class="glyphicon glyphicon-picture"></span>
                                <asp:HiddenField ID="hdfTxId" runat="server" Value='<%# Eval("id") %>' />
                            </asp:HyperLink>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="<span class='glyphicon glyphicon-check'></span>">
                        <ItemTemplate>
                            <asp:HiddenField ID="hdfID" runat="server" Value='<%# Eval("id") %>' />
                            <asp:CheckBox ID="chkSelected" runat="server" CssClass="chkRowSelect" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <EditRowStyle BackColor="#2461BF" />
                <EmptyDataTemplate>
                    <div class="alert alert-danger" role="alert" style="text-align: center; margin-bottom: 0;">
                        <p>ไม่พบข้อมูล</p>
                    </div>
                </EmptyDataTemplate>
                <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" Height="40" HorizontalAlign="Center" VerticalAlign="Middle" />
                <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" Height="30" />
                <RowStyle BackColor="#EFF3FB" />
                <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            </asp:GridView>
            <div style="text-align: right; margin-top: 5px;" id="divBottom" runat="server" visible="false">
                Selecct All
                <input type="checkbox" id="selectallBottom" />&nbsp;
            </div>

            <asp:Panel ID="pnlPagination" runat="server" CssClass="Pagination" Visible="false">
                <asp:Repeater ID="rptPageItem" runat="server" OnItemCommand="rptPageItem_ItemCommand">
                    <ItemTemplate>
                        <asp:LinkButton runat="server" ID="lnkPageNo" CommandName="ChangePage" CommandArgument='<%# Eval("PageId") %>'><%# Eval("PageNo") %></asp:LinkButton>
                    </ItemTemplate>
                </asp:Repeater>
            </asp:Panel>
            <asp:HiddenField ID="hdfPageId" runat="server" />
            <asp:HiddenField ID="hdfRowPerPage" runat="server" />
            <asp:HiddenField ID="hdfTotalRow" runat="server" />

            <asp:Panel ID="pnlConclude" runat="server" CssClass="text-right" Visible="false">
                <br />
                <p>
                    สรุป : Note 4
                    <asp:Label ID="lblNumNote4" runat="server"></asp:Label>
                    เครื่อง เงินส่วนต่าง
                    <asp:Label ID="lblDiffAmount" runat="server"></asp:Label>
                    บาท
                </p>
            </asp:Panel>

        </div>
    </div>
    <asp:Panel ID="pnlBottom" runat="server" CssClass="row" Visible="false">
        <br />
        <div class="row">
            <div class="col-md-2">
                <asp:Button ID="btnExport" runat="server" Text="Export" CssClass="btn btn-default" OnClick="btnExport_Click" />
            </div>
            <div class="col-md-10 text-right">
                อัพเดทสถานะ :
            <asp:RadioButtonList ID="rdoUpdateStat" runat="server" RepeatLayout="Flow" RepeatDirection="Horizontal">
                <asp:ListItem Text="&nbsp;จ่ายแล้ว&nbsp;&nbsp;&nbsp;" Value="จ่ายแล้ว"></asp:ListItem>
                <asp:ListItem Text="&nbsp;เอกสารไม่สมบูรณ์&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" Value="เอกสารไม่สมบูรณ์"></asp:ListItem>
            </asp:RadioButtonList>

                <asp:Button ID="btnSubmit" runat="server" Text="บันทึก" CssClass="btn btn-primary" OnClick="btnSubmit_Click" />
            </div>
        </div>
    </asp:Panel>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="script" runat="server">
    <script type="text/javascript">
        ActiveMenuIndex(0);

        $('.modalImage').magnificPopup({
            type: 'image',
            //removalDelay: 500,
            callbacks: {
                beforeOpen: function () {
                    this.st.mainClass = this.st.el.attr('data-effect');
                }
            }
        });

        $('#selectallTop').click(function (event) {
            if (this.checked) {
                $('.chkRowSelect').children("input[type=checkbox]").each(function () {
                    this.checked = true;
                });
            } else {
                $('.chkRowSelect').children("input[type=checkbox]").each(function () {
                    this.checked = false;
                });
            }
            $('#selectallBottom').prop('checked', this.checked);
        });

        $('#selectallBottom').click(function (event) {
            if (this.checked) {
                $('.chkRowSelect').children("input[type=checkbox]").each(function () {
                    this.checked = true;
                });
            } else {
                $('.chkRowSelect').children("input[type=checkbox]").each(function () {
                    this.checked = false;
                });
            }
            $('#selectallTop').prop('checked', this.checked);
        });

    </script>
</asp:Content>
